<div id="wrapper">
	<!-- Navigation -->
    <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/admin/">SlimCMS - Admin Panel</a>
	        <a href="/" class="btn btn-primary btn-xs navbar-to-site">Go to site</a>
        </div>
        <!-- /.navbar-header -->

        <ul class="nav navbar-top-links navbar-right">
            {% for item in menu_top.sortByMeta('sort').getChild() %}
            {% if item.getChild() %}
            <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="{{ item.link.url }}">
                    {% if item.link.attributes('icon') %}
                    <i class="{{ item.link.attributes('icon') }}"></i>  <i class="fa fa-caret-down"></i>
                    {% endif %}
                 </a>
                {{ item.link.text }}
                <ul class="dropdown-menu dropdown-user">
                    {% for item in item.getChild() %}
                        {% if item.meta('delimiter') %}
                            <li class="divider"></li>
                        {% else %}
                            <li><a href="{{ item.link.url }}">
                                {% if item.link.attributes('icon') %}
                                <i class="{{ item.link.attributes('icon') }}"></i>
                                {% endif %}
                                {{ item.link.text }}
                            </a></li>
                        {% endif %}
                    {% endfor %}
                </ul>
                <!-- /.dropdown-user -->
            </li>
            <!-- /.dropdown -->
            {% else %}
                <li>
                    <a href="{{ item.link.url }}">
                        {% if item.link.attributes('icon') %}
                        <i class="{{ item.link.attributes('icon') }}"></i>
                        {% endif %}
                        {{ item.link.text }}
                    </a>
                </li>
            {% endif %}
            {% endfor %}
        </ul>
        <!-- /.navbar-top-links -->
        <div class="navbar-default sidebar" role="navigation">
            <div class="sidebar-nav navbar-collapse">
                <ul class="nav" id="side-menu">
                {% for item in menu_left.sortByMeta('sort').getChild() %}
                    {% if not item.meta('onlyDevelopersMode') or system_options.isDevMode() %}
                    <li>
                    {% if item.getChild() %}
                        <a href="{{ item.link.url }}">
                            {% if item.link.attributes('icon') %}
                                <i class="{{ item.link.attributes('icon') }}"></i>
                            {% endif %}
                                {{ item.link.text }}<span class="fa arrow"></span>
                        </a>
                        <ul class="nav nav-second-level">
                        {% for item in item.getChild() %}
                            {% if not item.meta('onlyDevelopersMode') or system_options.isDevMode() %}
                            <li>
                                <a href="{{ item.link.url }}">
                                    {% if item.link.attributes('icon') %}
                                        <i class="{{ item.link.attributes('icon') }}"></i>
                                    {% endif %}
                                    {{ item.link.text }}
                                </a>
                            </li>
                            {% endif %}
                        {% endfor %}
                        </ul>
                    {% else %}
                        <a href="{{ item.link.url }}">
                            {% if item.link.attributes('icon') %}
                                <i class="{{ item.link.attributes('icon') }}"></i>
                            {% endif %}
                            {{ item.link.text }}
                        </a>
                    {% endif %}
                    </li>
                    {% endif %}
                {% endfor %}
                </ul>
            </div>
            <!-- /.sidebar-collapse -->
        </div>
        <!-- /.navbar-static-side -->
    </nav>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">
                    {% block headerh %}{{ h1 }}{% endblock %}
                    <div style="display:inline-block;float: right;">
                        {% block header_button %}
                        <a href="javascript:void(0);" data-target="#modal-config" data-toggle="modal" class="btn"><i class="fa fa-gears"></i></a>
                        <a href="{{ path_for(create_link) }}" class="btn btn-success">Create {{h1}}</a>
                        {% endblock %}
                    </div>
                </h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>
    {% if errors is defined %}
        <div style="margin-top: 25px;margin-bottom:5px;" class="alert alert-danger alert-dismissable">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            {{ errors }}
        </div>
    {% endif %}
    {% if success is defined %}
        <div style="margin-top: 25px;margin-bottom:5px;" class="alert alert-success alert-dismissable">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            {{ success }}
        </div>
    {% endif %}
